#include <iostream>
using namespace std;
void menu()
{
	cout<<"******************************"<<endl;
	cout<<"******* 1. Add  2. Miu *******"<<endl;
	cout<<"******* 3. Mul  4. Div *******"<<endl;
	cout<<"********** 0. exit  **********"<<endl;
	cout<<"******************************"<<endl;
	
}
int Add(int x,int y);
int Miu(int x,int y);
int Mul(int x,int y);
int Div(int x,int y);
//该处为回调函数 int (*pf)(int ,int)是该回调函数的参数类型为函数地址，所以可以直接传函数名称或者传&函数名称。
void cala(int (*pf)(int ,int));
{
	int ret = 0;
	int a,b;
	cout<<"请输入两个操作数->";
    cin>>a>>b;
    ret = pf(a,b);
    cout<<ret<<endl;
}
int main ()
{
    int input = 0;
    do
    {
    menu();
    cout<<"请选择->";
    cin>>input;
    switch(input)
    {
    	case 1:
    		cala(Add);
    	break;
    	case 2:
    		cala(Miu);
    	break;
    	case 3:
    		cala(Mul);
        break;
        case 4:
        	cala(Div);
        break;
        case 0:
        	cout<<"程序结束。";
        break;
        default:
        	cout<<"输入错误。"; 
        break;
	}
	}while(input);
	return 0;
}
int Add(int x,int y)
{
	return x + y;
}
int Miu(int x,int y)
{
	return x - y;
}
int Mul(int x,int y)
{
	return x * y;
}
int Div(int x,int y)
{
	return x / y;
}